/*
 * CView.m:
 *
 * implements CView  (subclass of view that handles user events)
 * written by : Jason R. Wilson  2/21/93
 */

#import "CView.h"
#import <dpsclient/wraps.h>
#import "NeXtInterface.h"
#import "engine.h"
#import <appkit/graphics.h>

@implementation CView

- clear:sender /* clear the screen */
{
  [self lockFocus];
  NXEraseRect(&bounds);
  DrawButtons();
  PSflushgraphics();
  [self unlockFocus];
  return self;
}

- wireframe:sender /* draw the full wireframe */
{
  [self lockFocus];
  DrawButtons();
  WireFrameFull();
  PSsetgray(NX_BLACK);
  PSstroke();
  PSflushgraphics();
  [self unlockFocus];
}

- refresh:sender /* render the scene (shaded) */
{
  renderit();
  Update();
  return self;
}

- forward:sender /* move forward */
{
  ChangeView(1);
  [self lockFocus];	
  NXEraseRect(&bounds);
  DrawButtons();
  WireFrame();
  PSsetgray(NX_BLACK);
  PSstroke();
  PSflushgraphics();
  [self unlockFocus];
  return self;
}

- backward:sender /* move backward */
{
  ChangeView(2);
  [self lockFocus];	
  NXEraseRect(&bounds);
  DrawButtons();
  WireFrame();
  PSsetgray(NX_BLACK);
  PSstroke();
  PSflushgraphics();
  [self unlockFocus];
  return self;
}

- turnleft:sender /* turn to the left */
{
  ChangeView(3);
  [self lockFocus];	
  NXEraseRect(&bounds);
  DrawButtons();
  WireFrame();
  PSsetgray(NX_BLACK);
  PSstroke();
  PSflushgraphics();
  [self unlockFocus];
  return self;
}

- turnright:sender /* turn to the right */
{
  ChangeView(4);
  [self lockFocus];	
  NXEraseRect(&bounds);
  DrawButtons();
  WireFrame();
  PSsetgray(NX_BLACK);
  PSstroke();
  PSflushgraphics();
  [self unlockFocus];
  return self;
}

- tiltup:sender  /* tilt head up */
{
  ChangeView(5);
  [self lockFocus];	
  NXEraseRect(&bounds);
  DrawButtons();
  WireFrame();
  PSsetgray(NX_BLACK);
  PSstroke();
  PSflushgraphics();
  [self unlockFocus];
  return self;
}

- tiltdown:sender /* tilt head down */
{
  ChangeView(6);
  [self lockFocus];	
  NXEraseRect(&bounds);
  DrawButtons();
  WireFrame();
  PSsetgray(NX_BLACK);
  PSstroke();
  PSflushgraphics();
  [self unlockFocus];
  return self;
}

- movefaster:sender /* move and turn faster */
{
  Faster();
}

- moveslower:sender /* move and turn slower */
{
  Slower();
}

- outputPPM:sender /* output view to a .ppm file */
{
  OutputPPM();
}

- subdivide:sender /* perform and adaptive subdivision pass */
{
  adapt();
  renderit();
  Update();
  return self;
}
